package org.hagen.mmia.yars.agent.utils;

import java.util.TreeMap;

public class IntegerTreeMap extends TreeMap<Object, Integer> {

	public Integer add(Object key, Integer value) {
		
		Integer entry;
		if( (entry = super.get( key )) != null ) {

			entry = value + entry; 
					
			return super.put( key, entry  );

		} else {

			return super.put(key, value);
		}
	}
	
	public Integer inc(Object key) {
		
		Integer entry;
		if( (entry = super.get( key )) != null ) {
			entry += 1; 
		} else {
			entry = 1;
		}

		return super.put( key, entry  );
	}
	
}
